<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%><%@ taglib prefix="c" 		uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt"		uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="fn" 		uri="http://java.sun.com/jsp/jstl/functions"
%><%@ taglib prefix="page"		uri="http://www.opensymphony.com/sitemesh/page"
%><fmt:setLocale value="ko" /><c:set var="path" value="${pageContext.request.contextPath}/" />
<fmt:parseDate value="${fn:substring(date,0,8)}" var="parsedDate" pattern="yyyyMMdd"/>
<c:set var="pageClick" value="" />
<c:if test="${groupId eq '2'}" >
<c:set var="pageClick" value="nclk(this, 'ttl.cabgen', '', '');" />
</c:if>
<c:if test="${groupId eq '3'}" >
<c:set var="pageClick" value="nclk(this, 'ttl.skygen', '', '');" />
</c:if>
<div id="ct">
	<div class="hh2" style="text-align:center">
		<h1><fmt:formatDate value="${parsedDate}" pattern="yyyy"/>.<fmt:formatDate value="${parsedDate}" pattern="MM"/>.<fmt:formatDate value="${parsedDate}" pattern="dd"/> <fmt:formatDate value="${parsedDate}" pattern="E"/></h1>
		<div class="pl"></div>
		<div class="pr" onclick="javascript:${pageClick} controlLayer();">
			<c:if test="${groupId != 1 and groupId != 9}">
				<a class="bt52"><span class="dw" id="spanText"></span></a>
			</c:if>
		</div>
	</div>
	<div class="pp2" id="layer" style="position:absolute; visibility:hidden;">
		<div id="channel" class="pp2w">
			<ul class="btg">
			<c:set var="lengthOfArray" value="${fn:length(channelClassList)}" />
				<c:set var="channelClassCount" value="0"/>
				<c:forEach items="${channelClassList}" var="channelClass">
					<c:if test="${not empty channelClass.className}">
						<li><a id="channelClass_${channelClassCount}" href="${path}channel/listByProgramTime.nhn?groupId=${groupId}&amp;classId=${channelClass.classId}&amp;date=${fn:substring(date,0,8)}&hour=${hour}&amp;selectedClassNumber=${channelClassCount}"><c:choose><c:when test="${channelClass.className eq '지상파'}">지상파</c:when><c:otherwise>${channelClass.className}</c:otherwise></c:choose></a></li>
						<c:set var="channelClassCount" value="${channelClassCount + 1}"/>
					</c:if>
				</c:forEach>
			</ul>
		</div>
	</div>		
	<p class="pgt">
		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '00'}">
				<fmt:parseDate value="23" var="prevHour" pattern="HH"/>					
			</c:when>
			<c:otherwise>
				<fmt:parseDate value="${fn:substring(date, 8, 10)-1}" var="prevHour" pattern="HH"/>
			</c:otherwise>
		</c:choose>
		
		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '00'}">
				<a class="bt4 bt4pv" href="${path}channel/listByProgramTime.nhn?menu=1&groupId=${groupId}&classId=${classId}&amp;selectedClassNumber=${selectedClassNumber}&date=${prevDate}&hour=<fmt:formatDate value="${prevHour}" pattern="HH"/>" onClick="nclk(this, 'ttl.hprev', '', '');">
			</c:when>
			<c:otherwise>
				<a class="bt4 bt4pv" href="${path}channel/listByProgramTime.nhn?menu=1&groupId=${groupId}&classId=${classId}&amp;selectedClassNumber=${selectedClassNumber}&date=<fmt:formatDate value="${parsedDate}" pattern="yyyyMMdd"/>&hour=<fmt:formatDate value="${prevHour}" pattern="HH"/>" onClick="nclk(this, 'ttl.hprev', '', '');">
			</c:otherwise>
		</c:choose>			
			<img alt="이전" src="http://static.naver.net/www/m/cm/im/bl.gif"/>
			<span class="hc">이전</span>
		</a>

		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '23'}">
				<fmt:parseDate value="00" var="parsedHour" pattern="HH"/>		
			</c:when>
			<c:otherwise>
				<fmt:parseDate value="${fn:substring(date, 8, 10)+1}" var="parsedHour" pattern="HH"/>
			</c:otherwise>
		</c:choose>		

		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '23'}">
				<span class="tm">${fn:substring(date, 8, 10)}:00 - 24:00</span>
			</c:when>
			<c:otherwise>
				<span class="tm">${fn:substring(date, 8, 10)}:00 - <fmt:formatDate value="${parsedHour}" pattern="HH"/>:00</span>
			</c:otherwise>
		</c:choose>	

		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '23'}">
				<fmt:parseDate value="00" var="nextHour" pattern="HH"/>					
			</c:when>
			<c:otherwise>
				<fmt:parseDate value="${fn:substring(date, 8, 10)+1}" var="nextHour" pattern="HH"/>	
			</c:otherwise>
		</c:choose>

		<c:choose>
			<c:when test="${fn:substring(date, 8, 10) == '23'}">
				<a class="bt4 bt4nx" href="${path}channel/listByProgramTime.nhn?groupId=${groupId}&classId=${classId}&amp;selectedClassNumber=${selectedClassNumber}&date=${nextDate}&hour=<fmt:formatDate value="${nextHour}" pattern="HH"/>" onClick="nclk(this, 'ttl.hnext', '', '');">			
			</c:when>
			<c:otherwise>
				<a class="bt4 bt4nx" href="${path}channel/listByProgramTime.nhn?groupId=${groupId}&classId=${classId}&amp;selectedClassNumber=${selectedClassNumber}&date=<fmt:formatDate value="${parsedDate}" pattern="yyyyMMdd"/>&hour=<fmt:formatDate value="${nextHour}" pattern="HH"/>" onClick="nclk(this, 'ttl.hnext', '', '');">
			</c:otherwise>
		</c:choose>
			<img alt="다음" src="http://static.naver.net/www/m/cm/im/bl.gif"/>
			<span class="hc">다음</span>
		</a>		
	</p>
	<ul class="li1">
		<c:forEach items="${listOfChannels}" var="channel" varStatus="loop">
			<li>				
				<a class="ct g" href="${path}program/list.nhn?menu=1&groupId=${groupId}&chNo=${channel.channelNo}&date=${fn:substring(date,0,8)}&classId=${channel.classId}" onClick="nclk(this, 'ttl.list', '', '');"><span class="wn">${channel.channelName}</span></a>
			</li>
			<li>
				<span class="ct">
					<c:forEach items="${channel.programList}" var="program" varStatus="">
						<c:set var="dateLength" value="${fn:length(program.beginTime)}" />
						<c:set var="hour" value="${fn:substring(program.beginTime, 8, 10)}" />
						<c:set var="minute" value="${fn:substring(program.beginTime, 10, dateLength)}" />
						<c:choose>
							<c:when test="${not empty program.subtitle}">
								<c:set var="title">${program.programName } &lt;${program.subtitle}&gt;</c:set>
							</c:when>
							<c:otherwise>
								<c:set var="title">${program.programName }</c:set>
							</c:otherwise>
						</c:choose>
						<!-- 프로그램  -->
						<span class="wn l2">
							<span class="elip">
								<span class="elip_in">
									<span class="elip_txt">
									<strong class="tr">${hour}:${minute}</strong>
										<!-- 프로그램  현재 방송 여부 -->
										<c:if test="${program.onAir == 'on' }"><span class="ic3 ic_on"><img src="http://static.naver.com/www/m/im/bl.gif" alt="방송중" /><span class="hc">방송중</span></span></c:if>
										${title}
									</span>
									<span class="elip_icon">
										<c:if test="${program.rebroadcast == 'Y'}"><span class="ic3 ic_re"><img src="http://static.naver.net/www/m/im/bl.gif" alt="재방송" /><span class="hc">재방송</span></span></c:if>
										<c:if test="${program.programClass == 19}"><span class="ic3 ic_19"><img src="http://static.naver.net/www/m/im/bl.gif" alt="19세이상관람가" /><span class="hc">19세이상관람가</span></span></c:if>					
										<c:if test="${program.programClass == 15}"><span class="ic3 ic_15"><img src="http://static.naver.net/www/m/im/bl.gif" alt="15세이상관람가" /><span class="hc">15세이상관람가</span></span></c:if>
										<c:if test="${program.programClass == 12}"><span class="ic3 ic_12"><img src="http://static.naver.net/www/m/im/bl.gif" alt="12세이상관람가" /> <span class="hc">12세이상관람가</span></span></c:if>
										<c:if test="${program.programClass == 7}"><span class="ic3 ic_7"><img src="http://static.naver.net/www/m/im/bl.gif" alt="7세이상관람가" /> <span class="hc">7세이상관람가</span></span></c:if>
									</span>
								</span>
							</span>																
						</span>
					</c:forEach>
				</span>
			</li>
		</c:forEach>
	</ul>
	<c:if test="${totalCount > pageSize}">
		<page:applyDecorator name="broadcast-listPaging"></page:applyDecorator>
	</c:if>
	<div class="sc6 sc61">
		<p class="bt7"><tvguide:mobile-epg-paging format="below_programTime" groupId="${groupId}" classId="${classId}" date="${date}" yesterdayOfDate="${yesterdayOfDate}" tomorrowOfDate="${tomorrowOfDate}" hour="${hour}" selectedClassNumber="${selectedClassNumber}"/></p>
	</div>
</div>
